import sys

from core import PasswordGeneratorFactory, CrackingFramework
from core.CrackingStatusMonitor import tip_printer
import fire


def uncompress_by_password_list(filepath, password_filepath):
    password = CrackingFramework.uncompress_by_password_list(
        filepath, PasswordGeneratorFactory.create_base_generator(password_filepath)
    )
    if password:
        tip_printer.print('解压成功，密码是' + password)
    else:
        tip_printer.print('解压失败，没有一个密码是对的')
        sys.exit(-1)


if __name__ == '__main__':
    fire.Fire(uncompress_by_password_list)
